using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace Western
{
    public class Client:DataAccess
    {
        public Client(string db_str)
        {
            CreateConnection(db_str);
        }
        
        public DataSet GetClientContract(string client_id, string client_type)
        {
            DataSet client_contract = new DataSet();
            try
            {
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = "sp_sel_EFClientContract";
                cmd.Parameters.Add("@ClntCode", SqlDbType.VarChar, 10).Value = client_id;
                cmd.Parameters.Add("@ClntType", SqlDbType.VarChar, 20).Value = client_type;
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                adpt.Fill(client_contract);

            }
            catch (Exception ex)
            {
                throw ex;
            }

            return client_contract;
        }
        public DataSet GetClientState(string client_id, string client_type)
        {
            DataSet client_contract = new DataSet();
            try
            {
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = "sp_sel_ClientAccount";
                cmd.Parameters.Add("@account_no", SqlDbType.VarChar, 10).Value = client_id;
                cmd.Parameters.Add("@client_type", SqlDbType.VarChar, 20).Value = client_type;
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                adpt.Fill(client_contract);

            }
            catch (Exception ex)
            {
                throw ex;
            }

            return client_contract;
        }
        public DataSet GetAccountTransaction(DateTime from_date, DateTime to_date, string client_id)
        {
            DataSet acct_trans = new DataSet();
            try
            {
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = "sp_sel_AccountTransaction";
                cmd.Parameters.Add("@FROM_DATE", SqlDbType.DateTime).Value = from_date;
                cmd.Parameters.Add("@TO_DATE", SqlDbType.DateTime).Value = to_date;
                cmd.Parameters.Add("@CLIENT_ID", SqlDbType.VarChar, 20).Value = client_id;
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                adpt.Fill(acct_trans);

            }
            catch (Exception ex)
            {
                throw ex;
            }

            return acct_trans;
        }
    }
}
